home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C++ / Applications / Muddweller 1.2 / source code / Main / DocDialogs.cp < prev    next >
Encoding:
Text File  |  1994-02-21  |  17.3 KB  |  633 lines  |  [TEXT/MPS ]

  1. /* DocDialogs - Implementation of the configuration dialogs                   */
  2.  
  3. #include "DocDialogs.h"
  4.  
  5.  
  6.         // • Toolbox
  7. #ifndef __ALIASES__
  8. #include "Aliases.h"
  9. #endif
  10.  
  11. #ifndef NUM_ALT_ADDRS
  12. #include "AddressXlation.h"
  13. #endif
  14.  
  15. #ifndef __GESTALTEQU__
  16. #include "GestaltEqu.h"
  17. #endif
  18.  
  19. #ifndef __RESOURCES__
  20. #include "Resources.h"
  21. #endif
  22.  
  23. #ifndef __STRINGS__
  24. #include "Strings.h"
  25. #endif
  26.  
  27.         // • Implementation use
  28. #ifndef __GLOBALS__
  29. #include "Globals.h"
  30. #endif
  31.  
  32. #ifndef __MTPSTUFF__
  33. #include "MTPStuff.h"
  34. #endif
  35.  
  36.  
  37. //------------------------------------------------------------------------------
  38.  
  39. const int kS7GetDirButton = 10;
  40. const int kS7GetDirNowButton = 11;
  41.  
  42. const int kGetDirButton = 11;
  43. const int kGetDirNowButton = 12;
  44.  
  45. const unsigned char kBullet = '•';
  46. const unsigned char kDummyVirtualCode = 49;
  47.  
  48. //------------------------------------------------------------------------------
  49.  
  50. pascal void GetCommValues (TMUDDoc *theDoc, TWindow *aWindow);
  51. pascal void GetPrefValues (TMUDDoc *theDoc, TWindow *aWindow);
  52. pascal void GetSetupValues (TMUDDoc *theDoc, TWindow *aWindow);
  53. pascal void GetTCPValues (TMUDDoc *theDoc, TWindow *aWindow);
  54.  
  55. pascal void SetCommValues (TMUDDoc *theDoc, TWindow *aWindow);
  56. pascal void SetPrefValues (TMUDDoc *theDoc, TWindow *aWindow);
  57. pascal void SetSetupValues (TMUDDoc *theDoc, TWindow *aWindow);
  58. pascal void SetTCPValues (TMUDDoc *theDoc, TWindow *aWindow);
  59.  
  60. //------------------------------------------------------------------------------
  61.  
  62. #pragma segment SDocDialogs
  63.  
  64. class TSelButton: public TButton {
  65. public:
  66.     virtual pascal void DoChoice (TView *origView, short itsChoice);
  67. };
  68.  
  69. static TMUDDoc *theSelDoc;
  70. static Boolean curDirValid;
  71. static short myRefNum;
  72. static long myCurDir;
  73. static StandardFileReply s7reply;
  74. static SFReply reply;
  75.  
  76. pascal short S7MyGetDirHook (short item, DialogPtr, void *)
  77. {
  78.     Str255 tmp;
  79.     CInfoPBRec pb;
  80.     FSSpec spec;
  81.     Boolean isFolder, wasAliased;
  82.  
  83.     switch (item) {
  84.     case kS7GetDirButton:
  85.         spec = s7reply.sfFile;
  86.         ResolveAliasFile (&spec, TRUE, &isFolder, &wasAliased);
  87.         if (isFolder) {
  88.             CopyStr255 (spec.name, tmp);
  89.             pb.dirInfo.ioNamePtr = tmp;
  90.             pb.dirInfo.ioVRefNum = spec.vRefNum;
  91.             pb.dirInfo.ioDrDirID = spec.parID;
  92.             pb.dirInfo.ioFDirIndex = 0;
  93.             PBGetCatInfo (&pb, FALSE);
  94.             myCurDir = pb.dirInfo.ioDrDirID;
  95.             myRefNum = spec.vRefNum;
  96.             curDirValid = true;
  97.             return sfItemCancelButton;
  98.         }
  99.         break;
  100.     case kS7GetDirNowButton:
  101.         myCurDir = *(long *)CurDirStore;
  102.         myRefNum = -(*(short *) SFSaveDisk);
  103.         curDirValid = true;
  104.         return sfItemCancelButton;
  105.     }
  106.     return item;
  107. }
  108.  
  109. pascal Boolean S7FoldersOnly (ParmBlkPtr p, void *)
  110. {
  111.     return (p->fileParam.ioFlAttrib & 0x10) == 0;
  112. }
  113.  
  114. pascal short MyGetDirHook (short item, DialogPtr)
  115. {
  116.     switch (item) {
  117.     case kGetDirButton:
  118.         if (reply.fType != 0) {
  119.             myRefNum = -(*(short *) SFSaveDisk);
  120.             myCurDir = reply.fType;
  121.             curDirValid = true;
  122.             return getCancel;
  123.         }
  124.         break;
  125.     case kGetDirNowButton:
  126.         myRefNum = -(*(short *) SFSaveDisk);
  127.         myCurDir = *(long *)CurDirStore;
  128.         curDirValid = true;
  129.         return getCancel;
  130.     }
  131.     return item;
  132. }
  133.  
  134. pascal Boolean FoldersOnly (ParmBlkPtr p)
  135. {
  136.     return (p->fileParam.ioFlAttrib & 0x10) == 0;
  137. }
  138.  
  139. pascal void TSelButton::DoChoice (TView *, short)
  140. {
  141.     Rect r;
  142.     DialogTHndl dlg;
  143.     Point loc;
  144.     Str255 tmp;
  145.     Boolean sys7;
  146.     long response;
  147.     OSErr err;
  148.     
  149.     err = Gestalt (gestaltAliasMgrAttr, &response);
  150.     sys7 = (err == noErr) && (response & (1 << gestaltAliasMgrPresent)) != 0;
  151.     if (sys7) {
  152.         err = Gestalt (gestaltStandardFileAttr, &response);
  153.         sys7 = (err == noErr) && (response & (1 << gestaltStandardFile58)) != 0;
  154.     }
  155.     if (sys7)
  156.         dlg = (DialogTHndl) GetResource ('DLOG', phS7GetDirID);
  157.     else
  158.         dlg = (DialogTHndl) GetResource ('DLOG', phGetDirID);
  159.     if (dlg != NULL) {
  160.         r = (**dlg).boundsRect;
  161.         CenterRectOnScreen (&r, TRUE, TRUE, TRUE);
  162.         loc.h = r.left;
  163.         loc.v = r.top;
  164.     } else {
  165.         loc.h = 100;
  166.         loc.v = 100;
  167.     }
  168.     gApplication->UpdateAllWindows ();
  169.     curDirValid = FALSE;
  170.     if (sys7)
  171.         CustomGetFile (S7FoldersOnly, -1, (SFTypeList) NULL, &s7reply,
  172.             phS7GetDirID, loc, S7MyGetDirHook, NULL, NULL, NULL, NULL);
  173.     else
  174.         SFPGetFile (loc, "\p", FoldersOnly, -1, (SFTypeList) NULL, MyGetDirHook,
  175.             &reply, phGetDirID, NULL);
  176.     if (curDirValid) MTPDirSetup (theSelDoc, myRefNum, myCurDir);
  177.     SetText (theSelDoc->fMTPDir, kDontRedraw);
  178.     ForceRedraw ();
  179. }
  180.  
  181.  
  182. //------------------------------------------------------------------------------
  183.  
  184. #pragma segment MACommandRes
  185.  
  186. class TTypeButton: public TButton {
  187. public:
  188.     unsigned long fFileType;
  189.     
  190.     virtual pascal void DoChoice (TView *origView, short itsChoice);
  191. };
  192.  
  193. pascal void TTypeButton::DoChoice (TView *, short)
  194. {
  195.     AppFile anAppFile;
  196.     FInfo info;
  197.     
  198.     if (gApplication->ChooseDocument (cPrefs, &anAppFile)) {
  199.         FailOSErr (GetFInfo (anAppFile.fName, anAppFile.vRefNum, &info));
  200.         fFileType = info.fdCreator;
  201.         SetText (anAppFile.fName, kDontRedraw);
  202.         ForceRedraw ();
  203.     }
  204. }
  205.  
  206.  
  207. //------------------------------------------------------------------------------
  208.  
  209. #pragma segment DlgRes
  210.  
  211. class TVT100Box: public TCheckBox {
  212. public:
  213.     virtual pascal void DoChoice (TView *origView, short itsChoice);
  214. };
  215.  
  216. pascal void TVT100Box::DoChoice (TView *origView, short itsChoice)
  217. {
  218.     TWindow *aWindow;
  219.     TCheckBox *aCheckBox;
  220.  
  221.     inherited::DoChoice (origView, itsChoice);
  222.     if (itsChoice == mCheckBoxHit) {
  223.         aWindow = GetWindow ();
  224.         aCheckBox = (TCheckBox *) aWindow->FindSubView ('skip');
  225.         aCheckBox->DimState (IsOn (), kRedraw);
  226.     }
  227. }
  228.  
  229.  
  230. //------------------------------------------------------------------------------
  231.  
  232. #pragma segment SDocDialogs
  233.  
  234. pascal void Communication (TMUDDoc *theDoc)
  235. {
  236.     TWindow *aWindow;
  237.     Boolean okPressed;
  238.     TDialogView *aDialogView;
  239.     
  240.     aWindow = NewTemplateWindow (kCommID, NULL);
  241.     FailNIL (aWindow);
  242.     SetCommValues (theDoc, aWindow);
  243.     aDialogView = (TDialogView *) aWindow->FindSubView ('DLOG');
  244.     okPressed = aDialogView->PoseModally () == 'OK  ';
  245.     if (okPressed) GetCommValues (theDoc, aWindow);
  246.     aWindow->Close ();
  247.     if (! okPressed) Failure (noErr, msgCancelled);
  248.     theDoc->fChangeCount += 1;
  249. }
  250.  
  251. //------------------------------------------------------------------------------
  252.  
  253. #pragma segment SDocDialogs
  254.  
  255. pascal void ConfigTCPHandler (short , long , void *Handler_StaticLink)
  256. {
  257.     ((TWindow *) Handler_StaticLink)->Close ();
  258. }
  259.  
  260. pascal void ConfigTCP (TMUDDoc *theDoc)
  261. {
  262.     TWindow *aWindow;
  263.     Boolean okPressed;
  264.     TDialogView *aDialogView;
  265.     FailInfo fi;
  266.     
  267.     aWindow = NewTemplateWindow (kConfigTCPID, NULL);
  268.     FailNIL (aWindow);
  269.     CatchFailures (&fi, ConfigTCPHandler, (void *) aWindow);
  270.     SetTCPValues (theDoc, aWindow);
  271.     aDialogView = (TDialogView *) aWindow->FindSubView ('DLOG');
  272.     okPressed = aDialogView->PoseModally () == 'OK  ';
  273.     if (okPressed) GetTCPValues (theDoc, aWindow);
  274.     Success (&fi);
  275.     aWindow->Close ();
  276.     if (! okPressed) Failure (noErr, msgCancelled);
  277.     theDoc->fChangeCount += 1;
  278. }
  279.  
  280. //------------------------------------------------------------------------------
  281.  
  282. #pragma segment SDocDialogs
  283.  
  284. pascal void GetCommValues (TMUDDoc *theDoc, TWindow *aWindow)
  285. {
  286. //    TNumberText *aNumberText;
  287.     TCluster *aCluster;
  288.     ResType aType;
  289.     TCheckBox *aCheckBox;
  290.     
  291. //    aNumberText = (TNumberText *) aWindow->FindSubView ('intc');
  292. //    theDoc->fInterrupt = (unsigned char) aNumberText->GetValue ();
  293.     aCluster = (TCluster *) aWindow->FindSubView ('eolc');
  294.     aType = aCluster->ReportCurrent ();
  295.     switch (aType) {
  296.     case 'eol1':
  297.         theDoc->fEndLine = 1;
  298.         break;
  299.     case 'eol2':
  300.         theDoc->fEndLine = 2;
  301.         break;
  302.     default:
  303.         theDoc->fEndLine = 0;
  304.         break;
  305.     }
  306.     aCheckBox = (TCheckBox *) aWindow->FindSubView ('teln');
  307.     theDoc->fUseTelnet = aCheckBox->IsOn ();
  308.     aCheckBox = (TCheckBox *) aWindow->FindSubView ('echo');
  309.     theDoc->fEcho = aCheckBox->IsOn ();
  310.     theDoc->fDoEcho = theDoc->fEcho;
  311.     aCheckBox = (TCheckBox *) aWindow->FindSubView ('vt10');
  312.     theDoc->fParseVT100 = aCheckBox->IsOn ();
  313.     aCheckBox = (TCheckBox *) aWindow->FindSubView ('skip');
  314.     theDoc->fSkipCR = aCheckBox->IsOn ();
  315. }
  316.  
  317. //------------------------------------------------------------------------------
  318.  
  319. #pragma segment SDocDialogs
  320.  
  321. pascal void GetPrefValues (TMUDDoc *theDoc, TWindow *aWindow)
  322. {
  323.     TEditText *aEditText;
  324.     TNumberText *aNumberText;
  325.     TPopup *aPopup;
  326.     TTypeButton *aTypeButton;
  327.     short item;
  328.     int i;
  329.     Str255 tmp;
  330.     TextStyle aStyle;
  331.     Boolean setStyle;
  332.     
  333.     aEditText = (TEditText *) aWindow->FindSubView ('name');
  334.     aEditText->GetText (tmp);
  335.     CopyStr255 (tmp, theDoc->fPlayer);
  336.     aEditText = (TEditText *) aWindow->FindSubView ('pass');
  337.     aEditText->GetText (tmp);
  338.     CopyStr255 (tmp, theDoc->fPasswd);
  339.     aPopup = (TPopup *) aWindow->FindSubView ('font');
  340.     item = aPopup->GetCurrentItem ();
  341.     GetItem (aPopup->fMenuHandle, item, tmp);
  342.     CopyStr255 (tmp, theDoc->fFontName);
  343.     item = GetFontNum (tmp);
  344.     setStyle = (theDoc->fFontNum != item);
  345.     theDoc->fFontNum = item;
  346.     aNumberText = (TNumberText *) aWindow->FindSubView ('tabs');
  347.     i = (int) aNumberText->GetValue ();
  348.     setStyle |= (theDoc->fTabSize != i);
  349.     theDoc->fTabSize = i;
  350.     aNumberText = (TNumberText *) aWindow->FindSubView ('size');
  351.     i = (int) aNumberText->GetValue ();
  352.     setStyle |= (theDoc->fFontSize != i);
  353.     theDoc->fFontSize = i;
  354.     aNumberText = (TNumberText *) aWindow->FindSubView ('logs');
  355.     theDoc->fLogSize = (int) aNumberText->GetValue ();
  356.     aNumberText = (TNumberText *) aWindow->FindSubView ('hist');
  357.     theDoc->fHistSize = (int) aNumberText->GetValue ();
  358.     aTypeButton = (TTypeButton *) aWindow->FindSubView ('ftyp');
  359.     aTypeButton->GetText (tmp);
  360.     CopyStr255 (tmp, theDoc->fCreatorApp);
  361.     theDoc->fTextSig = aTypeButton->fFileType;
  362.     if (setStyle) {
  363.         aStyle.tsFont = theDoc->fFontNum;
  364.         aStyle.tsFace = 0;
  365.         aStyle.tsSize = theDoc->fFontSize;
  366.         aStyle.tsColor = gRGBBlack;
  367.         theDoc->fLogWindow->fLogView->SetBaseStyle (&aStyle, kRedraw);
  368.         theDoc->fLogWindow->fCommandView->SetBaseStyle (&aStyle, kRedraw);
  369.     }
  370. }
  371.  
  372. //------------------------------------------------------------------------------
  373.  
  374. #pragma segment SDocDialogs
  375.  
  376. pascal void GetSetupValues (TMUDDoc *theDoc, TWindow *aWindow)
  377. {
  378.     TCheckBox *aCheckBox;
  379.     TNumberText *aNumberText;
  380.     TCluster *aCluster;
  381.     ResType aType;
  382.     
  383.     aCluster = (TCluster *) aWindow->FindSubView ('prot');
  384.     aType = aCluster->ReportCurrent ();
  385.     switch (aType) {
  386.     case 'pro1':
  387.         theDoc->fProtocol = 1;
  388.         break;
  389.     default:
  390.         theDoc->fProtocol = 0;
  391.         break;
  392.     }
  393.     aCheckBox = (TCheckBox *) aWindow->FindSubView ('ctab');
  394.     theDoc->fCvtTab = aCheckBox->IsOn ();
  395.     aNumberText = (TNumberText *) aWindow->FindSubView ('tabw');
  396.     theDoc->fSTab = (int) aNumberText->GetValue ();
  397.     aCheckBox = (TCheckBox *) aWindow->FindSubView ('updt');
  398.     theDoc->fUpdate = aCheckBox->IsOn ();
  399. }
  400.  
  401. //------------------------------------------------------------------------------
  402.  
  403. #pragma segment SDocDialogs
  404.  
  405. pascal void GetTCPValues (TMUDDoc *theDoc, TWindow *aWindow)
  406. {
  407.     TEditText *aEditText;
  408.     TNumberText *aNumberText;
  409.     Str255 tmp;
  410.     
  411.     aEditText = (TEditText *) aWindow->FindSubView ('addr');
  412.     aEditText->GetText (tmp);
  413.     CopyStr255 (tmp, theDoc->fHostName);
  414.     aNumberText = (TNumberText *) aWindow->FindSubView ('port');
  415.     theDoc->fTCPPort = (int) aNumberText->GetValue ();
  416.     aNumberText = (TNumberText *) aWindow->FindSubView ('mtpp');
  417.     theDoc->fMTPPort = (int) aNumberText->GetValue ();
  418. }
  419.  
  420. //------------------------------------------------------------------------------
  421.  
  422. #pragma segment SDocDialogs
  423.  
  424. pascal void Preferences (TMUDDoc *theDoc)
  425. {
  426.     TWindow *aWindow;
  427.     Boolean okPressed;
  428.     TDialogView *aDialogView;
  429.     
  430.     aWindow = NewTemplateWindow (kPrefsID, NULL);
  431.     FailNIL (aWindow);
  432.     SetPrefValues (theDoc, aWindow);
  433.     aDialogView = (TDialogView *) aWindow->FindSubView ('DLOG');
  434.     okPressed = aDialogView->PoseModally () == 'OK  ';
  435.     if (okPressed) GetPrefValues (theDoc, aWindow);
  436.     aWindow->Close ();
  437.     if (!okPressed) Failure (noErr, msgCancelled);
  438.     theDoc->fLogWindow->fLogView->SetMaxSize (theDoc->fLogSize * 1024);
  439.     theDoc->fLogWindow->fCommandView->SetHistSize (theDoc->fHistSize);
  440.     theDoc->fChangeCount += 1;
  441. }
  442.  
  443. //------------------------------------------------------------------------------
  444.  
  445. #pragma segment SDocDialogs
  446.  
  447. pascal void SetCommValues (TMUDDoc *theDoc, TWindow *aWindow)
  448. {
  449. //    TNumberText *aNumberText;
  450.     TRadio *aRadio;
  451.     ResType aType;
  452.     TCheckBox *aCheckBox;
  453.     
  454. //    aNumberText = (TNumberText *) aWindow->FindSubView ('intc');
  455. //    aNumberText->SetValue (theDoc->fInterrupt, kDontRedraw);
  456.     switch (theDoc->fEndLine) {
  457.     case 1:
  458.         aType = 'eol1';
  459.         break;
  460.     case 2:
  461.         aType = 'eol2';
  462.         break;
  463.     default:
  464.         aType = 'eol0';
  465.         break;
  466.     }
  467.     aRadio = (TRadio *) aWindow->FindSubView (aType);
  468.     aRadio->SetState (TRUE, kDontRedraw);
  469.     aCheckBox = (TCheckBox *) aWindow->FindSubView ('teln');
  470.     aCheckBox->SetState (theDoc->fUseTelnet, kDontRedraw);
  471.     aCheckBox = (TCheckBox *) aWindow->FindSubView ('echo');
  472.     aCheckBox->SetState (theDoc->fEcho, kDontRedraw);
  473.     aCheckBox = (TCheckBox *) aWindow->FindSubView ('vt10');
  474.     aCheckBox->SetState (theDoc->fParseVT100, kDontRedraw);
  475.     aCheckBox = (TCheckBox *) aWindow->FindSubView ('skip');
  476.     aCheckBox->SetState (theDoc->fSkipCR, kDontRedraw);
  477.     aCheckBox->DimState (theDoc->fParseVT100, kDontRedraw);
  478. }
  479.  
  480. //------------------------------------------------------------------------------
  481.  
  482. #pragma segment SDocDialogs
  483.  
  484. pascal void SetPrefValues (TMUDDoc *theDoc, TWindow *aWindow)
  485. {
  486.     TEditText *aEditText;
  487.     TNumberText *aNumberText;
  488.     TPopup *aPopup;
  489.     TTypeButton *aTypeButton;
  490.     short num, item;
  491.     Str255 tmp, aFontName;
  492.     
  493.     aEditText = (TEditText *) aWindow->FindSubView ('name');
  494.     CopyStr255 (theDoc->fPlayer, tmp);
  495.     aEditText->SetText (tmp, kDontRedraw);
  496.     aEditText = (TEditText *) aWindow->FindSubView ('pass');
  497.     CopyStr255 (theDoc->fPasswd, tmp);
  498.     aEditText->SetText (tmp, kDontRedraw);
  499.     aPopup = (TPopup *) aWindow->FindSubView ('font');
  500.     AddResMenu (aPopup->fMenuHandle, 'FONT');
  501.     aPopup->AdjustBotRight ();
  502.     CopyStr255 (theDoc->fFontName, tmp);
  503.     num = CountMItems (aPopup->fMenuHandle);
  504.     for (item = 1; item < num; item++) {
  505.         GetItem (aPopup->fMenuHandle, item, aFontName);
  506.         if (CompareStrings (tmp, aFontName) == 0) {
  507.             aPopup->SetCurrentItem (item, kDontRedraw);
  508.             break;
  509.         }
  510.     }
  511.     aNumberText = (TNumberText *) aWindow->FindSubView ('size');
  512.     aNumberText->SetValue (theDoc->fFontSize, kDontRedraw);
  513.     aNumberText = (TNumberText *) aWindow->FindSubView ('tabs');
  514.     aNumberText->SetValue (theDoc->fTabSize, kDontRedraw);
  515.     aNumberText = (TNumberText *) aWindow->FindSubView ('logs');
  516.     aNumberText->SetValue (theDoc->fLogSize, kDontRedraw);
  517.     aNumberText = (TNumberText *) aWindow->FindSubView ('hist');
  518.     aNumberText->SetValue (theDoc->fHistSize, kDontRedraw);
  519.     aTypeButton = (TTypeButton *) aWindow->FindSubView ('ftyp');
  520.     CopyStr255 (theDoc->fCreatorApp, tmp);
  521.     aTypeButton->SetText (tmp, kDontRedraw);
  522.     aTypeButton->fFileType = theDoc->fTextSig;
  523. }
  524.  
  525. //------------------------------------------------------------------------------
  526.  
  527. #pragma segment SDocDialogs
  528.  
  529. pascal void SetSetupValues (TMUDDoc *theDoc, TWindow *aWindow)
  530. {
  531.     TCheckBox *aCheckBox;
  532.     TNumberText *aNumberText;
  533.     TButton *aButton;
  534.     Str255 tmp;
  535.     TRadio *aRadio;
  536.     ResType aType;
  537.     
  538.     switch (theDoc->fProtocol) {
  539.     case 1:
  540.         aType = 'pro1';
  541.         break;
  542.     default:
  543.         aType = 'pro0';
  544.         break;
  545.     }
  546.     aRadio = (TRadio *) aWindow->FindSubView (aType);
  547.     aRadio->SetState (TRUE, kDontRedraw);
  548.     theSelDoc = theDoc;
  549.     aCheckBox = (TCheckBox *) aWindow->FindSubView ('ctab');
  550.     aCheckBox->SetState (theDoc->fCvtTab, kDontRedraw);
  551.     aNumberText = (TNumberText *) aWindow->FindSubView ('tabw');
  552.     aNumberText->SetValue (theDoc->fSTab, kDontRedraw);
  553.     aCheckBox = (TCheckBox *) aWindow->FindSubView ('updt');
  554.     aCheckBox->SetState (theDoc->fUpdate, kDontRedraw);
  555.     aButton = (TButton *) aWindow->FindSubView ('dsel');
  556.     CopyStr255 (theDoc->fMTPDir, tmp);
  557.     aButton->SetText (tmp, kDontRedraw);
  558. }
  559.  
  560. //------------------------------------------------------------------------------
  561.  
  562. #pragma segment SDocDialogs
  563.  
  564. pascal void SetTCPValues (TMUDDoc *theDoc, TWindow *aWindow)
  565. {
  566.     TEditText *aEditText;
  567.     TNumberText *aNumberText;
  568.     Str255 tmp;
  569.     
  570.     CopyStr255 (theDoc->fHostName, tmp);
  571.     aEditText = (TEditText *) aWindow->FindSubView ('addr');
  572.     aEditText->SetText (tmp, kDontRedraw);
  573.     aNumberText = (TNumberText *) aWindow->FindSubView ('port');
  574.     aNumberText->SetValue (theDoc->fTCPPort, kDontRedraw);
  575.     aNumberText = (TNumberText *) aWindow->FindSubView ('mtpp');
  576.     aNumberText->SetValue (theDoc->fMTPPort, kDontRedraw);
  577. }
  578.  
  579. //------------------------------------------------------------------------------
  580.  
  581. #pragma segment SDocDialogs
  582.  
  583. static Str31 oldVol, oldDir;
  584. static long oldDirID;
  585. static short oldVRefNum;
  586.  
  587. pascal void SetupHandler (short , long , void *theDoc)
  588. {
  589.     CopyStr255 (oldVol, ((TMUDDoc *)theDoc)->fMTPVol);
  590.     CopyStr255 (oldDir, ((TMUDDoc *)theDoc)->fMTPDir);
  591.     ((TMUDDoc *)theDoc)->fMTPDirID = oldDirID;
  592.     ((TMUDDoc *)theDoc)->fMTPVRefNum = oldVRefNum;
  593. }
  594.  
  595. pascal void Setup (TMUDDoc *theDoc)
  596. {
  597.     TWindow *aWindow;
  598.     Boolean okPressed;
  599.     TDialogView *aDialogView;
  600.     FailInfo fi;
  601.     
  602.     aWindow = NewTemplateWindow (kSetupID, NULL);
  603.     FailNIL (aWindow);
  604.     SetSetupValues (theDoc, aWindow);
  605.     CopyStr255 (theDoc->fMTPVol, oldVol);
  606.     CopyStr255 (theDoc->fMTPDir, oldDir);
  607.     oldDirID = theDoc->fMTPDirID;
  608.     oldVRefNum = theDoc->fMTPVRefNum;
  609.     aDialogView = (TDialogView *) aWindow->FindSubView ('DLOG');
  610.     CatchFailures (&fi, SetupHandler, (void *) theDoc);
  611.     okPressed = aDialogView->PoseModally () == 'OK  ';
  612.     if (okPressed) GetSetupValues (theDoc, aWindow);
  613.     aWindow->Close ();
  614.     if (!okPressed) Failure (noErr, msgCancelled);
  615.     Success (&fi);
  616.     theDoc->fChangeCount += 1;
  617. }
  618.  
  619. //------------------------------------------------------------------------------
  620.  
  621. #pragma segment MAInit
  622.  
  623. pascal void InitDocDialogs (void)
  624. {
  625.     if (gDeadStripSuppression) {
  626.         TSelButton *aSelButton = new TSelButton;
  627.         TTypeButton *aTypeButton = new TTypeButton;
  628.         TVT100Box *aVT100Box = new TVT100Box;
  629.     }
  630. }
  631.  
  632. //------------------------------------------------------------------------------
  633.